package se.opendataexchange.simulator;

import se.opendataexchange.common.AddressValue;

public class SimulatedAnalogValue extends AddressValue {
	FunctionGenerator gen;
	public SimulatedAnalogValue(String name, String generator, long interval) {
		setName(name);
		if(generator.contains("Sin")){
			gen = new MathGenerator(this,interval,MathGenerator.FunctionType.SIN);
		}else if(generator.contains("Cos")){
			gen = new MathGenerator(this, interval, MathGenerator.FunctionType.COS);
		}else if(generator.contains("Saw")){
			gen = new MathGenerator(this, interval, MathGenerator.FunctionType.REST10);
		}else{
			System.err.println("Wrong generator string. ");
			gen = new MathGenerator(this,interval,MathGenerator.FunctionType.SIN);
		}
		System.out.println("Creating ."+getName()+".");
		Simulator.addSimulatedValue(gen);
	}
	
	public SimulatedAnalogValue(String name, String generator) {
		setName(name);
		if(generator.contains("Sin")){
			gen = new MathGenerator(this,100,MathGenerator.FunctionType.SIN);
		}else if(generator.contains("Cos")){
			gen = new MathGenerator(this, 100, MathGenerator.FunctionType.COS);
		}else if(generator.contains("Saw")){
			gen = new MathGenerator(this, 100, MathGenerator.FunctionType.REST10);
		}else{
			System.err.println("Wrong generator string. ");
			gen = new MathGenerator(this, 100,MathGenerator.FunctionType.SIN);
		}
		System.out.println("Creating ."+getName()+".");
		Simulator.addSimulatedValue(gen);
	}
	
}
